import pandas as pd
import matplotlib.pyplot as plt

# 设置中文字体和负号正常显示
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

# 读取数据
df = pd.read_csv('C:\\Users\\LENOVO\\Desktop\\数据可视化\\job_clean.csv', sep=',', header=None, names=[
    "id", "job_type", "job_title", "annual_salary", "company_type", "company_size", "city"
])

# 绘制箱型图
plt.figure(figsize=(8, 6))
df.boxplot(column='annual_salary', by='company_type', grid=False)
plt.title("公司类型与年薪分布")
plt.suptitle('')
plt.xlabel("公司类型")
plt.ylabel("年薪")
plt.tight_layout()
plt.show()
